{ "nodes": [ { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "3", "name": "N", "type": "int", "uid": 2 }, { "expr": "1.5\n", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0aam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Y',float('-1.500000'),float('-1.500000'),float('-inf'),float('1.500000'),float('1.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -451.76388222470047, -362.669378407898 ], "name": "p0", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "import math", "", "title('Polygon')", "", "input('x', float)", "input('y', float)", "input('N', int)", "input('r', float)", "", "output('shape', fab.shapes.move(fab.shapes.polygon_radius(x, y, r, N), x, y))", "", "# UI", "# (we need to do a bit of work to make the UI work for both even and", "# odd vertex counts; otherwise it will be off for one or the other)", "a_ = 0 if (N % 2) else (math.pi / N)", "sb.ui.wireframe([", " (x + r * math.sin(a_ + a * math.pi * 2/N),", " y + r * math.cos(a_ + a * math.pi * 2/N), 0)", " for a in range(N)], close=True)", "sb.ui.point(x, y)", "sb.ui.point(x + r * math.sin(a_), y + r * math.cos(a_),", " drag=(None, r, None))", "" ], "uid": 0 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "\u0011[__0.__3]", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.2", "name": "width", "type": "float", "uid": 2 }, { "expr": "1.25", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125',float('-0.100000'),float('0.875000'),float('-inf'),float('0.100000'),float('2.125000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -152.90849704920186, -307.4297302203029 ], "name": "r0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rectangle (center)')", "", "input('x0', float)", "input('y0', float)", "input('width', float)", "input('height', float)", "", "xmin, xmax = x0 - width/2, x0 + width/2", "ymin, ymax = y0 - height/2, y0 + height/2", "", "output('shape', fab.shapes.rectangle(xmin, xmax, ymin, ymax))", "", "def drag_hw(this, x, y, z):", " this.width = abs(2 * (x - this.x0))", " this.height = abs(2 * (y - this.y0))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.point(x0, y0)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "" ], "uid": 1 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "1.2", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.3", "name": "x1", "type": "float", "uid": 2 }, { "expr": "1.5", "name": "y1", "type": "float", "uid": 3 }, { "expr": "-0.3", "name": "x2", "type": "float", "uid": 4 }, { "expr": "1.5", "name": "y2", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5',float('-0.300000'),float('1.200000'),float('-inf'),float('0.300000'),float('1.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ -145.6394477719945, -95.47068022075567 ], "name": "t0", "script": [ "import fab", "", "title('Triangle')", "", "input('x0', float)", "input('y0', float)", "input('x1', float)", "input('y1', float)", "input('x2', float)", "input('y2', float)", "", "output('shape', fab.shapes.triangle(x0, y0, x1, y1, x2, y2))", "", "# UI", "sb.ui.wireframe([(x0, y0, 0), (x1, y1, 0), (x2, y2, 0)], close=True)", "sb.ui.point(x0, y0, 0)", "sb.ui.point(x1, y1, 0)", "sb.ui.point(x2, y2, 0)", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__1.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__2.__6]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5',float('-0.300000'),float('0.875000'),float('-inf'),float('0.300000'),float('2.125000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 162.63412515858852, -157.2467184300246 ], "name": "u0", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 3 }, { "datums": [ { "expr": "\u0011[__3.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0.0", "name": "x", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 2 }, { "expr": "\u0011[__0.__2]", "name": "n", "type": "int", "uid": 3 }, { "expr": "\u0012fab.types.Shape('iim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5',float('-1.990303'),float('-1.322307'),float('-inf'),float('1.990303'),float('2.125000'),float('inf'))", "name": "array", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 422.86885683814637, -401.32362109735936 ], "name": "a0", "script": [ "import fab", "import math", "", "title('Array (polar)')", "", "input('shape', fab.types.Shape)", "input('x', float)", "input('y', float)", "input('n', int)", "", "output('array', fab.shapes.iterate_polar(shape, x, y, n))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * 0.3 + x,", " math.sin(i/36. * 2*math.pi) * 0.3 + y, 0)", " for i in range(36)], close=True, color=sb.color.teal)", "", "sb.ui.point(x, y, 0, color=sb.color.teal)", "" ], "uid": 4 }, { "datums": [ { "expr": "\u0011[__0.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__4.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0aam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Yniim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5',float('-1.500000'),float('-1.500000'),float('-inf'),float('1.500000'),float('1.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 734.2147476858345, -241.82127904623016 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 5 }, { "datums": [ { "expr": "\u0011[__5.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0aam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Ym-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-0.75Yniim-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5m-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf-0-Yf-0-Zf0iaa-f-0.1X-Xf0.1a-f0.875Y-Yf2.125ni-*f-0.3-Xf0.3*f-0.3-Yf1.5i-*f0.3-Xf0*f-0.3-Yf1.2-*f0-Xf-0.3*f0.6-Yf1.5',float('-1.500000'),float('-1.500000'),float('-inf'),float('1.500000'),float('1.500000'),float('inf'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 906.3562302321152, -69.0080580214959 ], "name": "h0", "script": [ "import fab", "", "title('Heightmap (.png)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.heightmap(shape)", "" ], "uid": 6 } ], "protocol": 6, "type": "sb" }